<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var minSteps = function (n) {
      let dp = new Array(n + 1).fill(Infinity)
      dp[1] = 0
      for (let i = 1; i <= n; i++) {
        for (let k = 1; k * i <= n; k++) {
          dp[k * i] = Math.min(dp[k * i], dp[i] + k)
        }
      }
      return dp[n]
    };
    console.log(minSteps(n = 1))
  </script>
</body>

</html>